<template>
	<view class="container">
		<!-- 顶部标题栏 -->
		<view class="header" @click="dingbuRecord">
			<image :src="avaterUrl" class="touxiang"> </image>
			<text class="title">{{nickname}}</text>
		</view>

		<!-- 菜单 -->
		<view class="menu-list">
			<view class="menu-item" v-for="(item, index) in menuItems" :key="index" @click="MenuItem(item)">
				<view class="menu-left">
					<image v-if="item.icon" class="menu-icon" :src="item.icon"></image>
					<text class="menu-text">{{item.name}}</text>
				</view>

				<image class="arrowleft" src="/static/my/arrowleft.png"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuItems: [{
						name: '师傅入驻审核',
						path: '/pages/my/master/index',
						icon: '/static/my/master.png'
					},
					{
						name: '台尼调货中心',
						path: '/pages/my/taini/index',
						icon: '/static/my/taini.png'
					},
					{
						name: '我的发单记录',
						path: '/pages/fadanjilu/index',
						icon: '/static/my/order.png'
					},
					{
						name: '我的接单记录',
						path: '/pages/my/receive/index',
						icon: '/static/my/receive.png'
					},
					{
						name: '我要投诉师傅',
						path: '/pages/my/tousu/index',
						icon: '/static/my/tousu.png'
					},
					{
						name: '消息推送设置',
						path: '/pages/my/tuisong/index',
						icon: '/static/my/tuisong.png'
					},
					{
						name: '地址簿管理',
						path: '/pages/my/address/index',
						icon: '/static/my/address.png'
					},
					{
						name: '联系客服',
						path: '/pages/my/connect/index',
						icon: '/static/my/connect.png'
					},
					{
						name: '发布商品',
						path: '/pages/category/fabu/index',
						icon: '/static/my/fabu.png'
					},
					{
						name: '赛事发布',
						path: '/pages/my/honor/honor',
						icon: '/static/my/fabisai.png'
					},
					{
						name: '参加赛事',
						path: '/pages/my/honor/bisai',
						icon: '/static/my/honor.png'
					}
				],
				nickname: '微信用户',
				avaterUrl: '/static/my/user.png'
			}
		},

		onLoad() {
			this.$http.get('/users').then((res) => {
				console.log(res)
			})
		},
		methods: {
			dingbuRecord() {
				console.log('尝试跳转到：/pages/user/index')
				uni.navigateTo({
					url: "/pages/my/user/index",
					success: () => {
						console.log('成功跳转到：/pages/my/user/index')
					},
					fail: (err) => {
						console.error('跳转失败：', err)
					}
				})
			},
			MenuItem(item) {
				console.log('点击的菜单项：', item.name);
				console.log('跳转路径：', item.path)
				uni.navigateTo({
					url: item.path,
					fail: (err) => {
						console.log('跳转失败：', err);

					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 10rpx;
		background-color: #f5f5f5;
		min-height: 100vh;
	}

	.header {
		padding: 30rpx 0;
		border-bottom: 1rpx solid #eee;
		margin-bottom: 20rpx;
		display: flex;

		align-items: center;

		.title {
			font-size: 36rpx;
			font-weight: bold;
			color: #333;
			text-align: center;
			margin-left: 45rpx;
		}

		.touxiang {
			width: 150rpx;
			height: 150rpx;
			margin-left: 30rpx;

		}
	}

	.menu-list {
		background-color: #fff;
		border-radius: 12rpx;
		overflow: hidden;
		box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);

		.menu-item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx;
			border-bottom: 1rpx solid #f0f0f0;

			&:last-child {
				border-bottom: none;
			}

			.menu-left {
				display: flex; //让文字和图标在同一排
				align-items: center;

				.menu-icon {
					width: 45rpx;
					height: 45rpx;
					margin-right: 40rpx;
					box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.02);

				}

				.menu-text {
					font-size: 30rpx;
					color: #333;

				}
			}

			.arrowleft {
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
</style>